package com.group9.handinhand.service.so;

import java.util.Date;

import org.springframework.beans.BeanUtils;

import com.group9.handinhand.dao.model.AbstractBaseModel;
/**
 * Class for Base service class SO
 *
 */
public abstract class AbstractBaseSO {
	
	private Long id;
    private Date createDate = new Date();
    private Date updateDate = new Date();

	protected <T extends AbstractBaseModel> T convert(T model) {
		 return convert(model, null);
	}

	protected <T extends AbstractBaseModel> T convert(T model, String[] ignoreProperties) {
		BeanUtils.copyProperties(this, model, ignoreProperties);
		return model;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	/**
	 * to string method for the AbstractBaseSO class
	 */
	@Override
	public String toString() {
		return "AbstractBaseSO [id=" + id + ", createDate=" + createDate
				+ ", updateDate=" + updateDate + "]";
	}
	

    @Override
    /**
     * the method for equality
     */
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (!(obj instanceof AbstractBaseSO))
	    return false;
	AbstractBaseSO other = (AbstractBaseSO) obj;
	if (getId() == null) {
		return false;
	} else if (!getId().equals(other.getId())) {
	    return false;
	}
	return true;
    }
    

}
